//
//  MBScrollViewHeaderView.m
//  MemberBusiness-ios
//
//  Created by cherry pu on 2018/5/4.
//  Copyright © 2018年 zhangXin. All rights reserved.
//

#import "MBScrollViewHeaderView.h"

@interface MBScrollViewHeaderView ()
@property (nonatomic,strong)UILabel* titleLabel;
@property (nonatomic,strong)UIImageView* headerImageView;

@end

@implementation MBScrollViewHeaderView

-(instancetype)init
{
    if (self = [super init]) {
        [self mas_makeConstraints:^(MASConstraintMaker *make) {
            make.width.mas_equalTo(SCREEN_WIDTH);
            make.height.mas_equalTo([UIView lf_sizeFromIphone6:35]);
        }];
        
        UIImageView* headerImageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"commodity_detail_header"]];
        self.headerImageView = headerImageView;
        [self addSubview:headerImageView];
        
        [headerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.equalTo(self.mas_centerY);
            make.centerX.equalTo(self);
        }];
        
        UILabel* titleLabel = [[UILabel alloc]init];
        self.titleLabel = titleLabel;
        titleLabel.font = [UIFont lf_systemFontOfSize:11];
        titleLabel.textColor = [UIColor colorWithWhite:0 alpha:0.8];
        titleLabel.text = @"下拉，返回宝贝详情";
        [self addSubview:titleLabel];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.centerX.equalTo(self);
        }];
    }
    return self;
}

-(void)setTitle:(NSString *)title {
    _title = title;
    if ([title hasPrefix:@"下拉"]) {
        self.headerImageView.transform = CGAffineTransformMakeRotation(0.000001 - M_PI);
    }else {
        self.headerImageView.transform = CGAffineTransformMakeRotation(M_PI*2);
    }
    self.titleLabel.text = title;
}

@end
